/*
 * 文件名：CarInAndOutController.java	 
 * 时     间：下午8:07:54
 * 作     者：binghen       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.controller.index;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cz073586.tools.date.DateFormatString;
import com.cz073586.tools.date.DateTools;
import com.cz073586.tools.util.ThreadPoolUtil;
import com.local.common.LogInfoConstan;
import com.local.dao.hismappers.CarParkOutCopyMapper;
import com.local.dao.mapers.CarParkInMapper;
import com.local.dao.mapers.CarParkOutMapper;
import com.local.dao.mapers.LocalCarTypeMapper;
import com.local.dao.mapers.ParklotNumberMapper;
import com.local.entity.vo.CalculateBillPriceVo;
import com.local.entity.vo.CarBillVo;
import com.local.entity.vo.CarOutInfoVo;
import com.local.entity.vo.CarParkInOverVo;
import com.local.entity.vo.EquimentErroVo;
import com.local.entity.vo.InstructVo;
import com.local.entity.vo.ParkwellPayBillVo;
import com.local.entity.vo.ShowCarOutBillParameterVo;
import com.local.manager.locks.RecordLockManager;
import com.local.manager.thread.CarParkInLocalThread;
import com.local.manager.thread.CarParkOutThread;
import com.local.manager.thread.FtpImageUpThread;
import com.local.manager.thread.ParkTwoScreenMsgThread;
import com.local.manager.thread.StayCarOutThread;
import com.local.model.CarParkIn;
import com.local.model.CarParkOut;
import com.local.model.CarParkOutCopy;
import com.local.model.LocalCarType;
import com.local.model.Log;
import com.local.model.LogExample;
import com.local.service.face.CarInAndOutService;
import com.local.service.face.CrossingService;
import com.local.service.face.LogService;
import com.local.service.face.ParkwellCarOutService;
import com.local.util.MyDateUtil;
import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;
import com.qianhai.common.utils.Log4jUtil;
import com.qianhai.common.utils.Tools;
import com.qianhai.common.utils.UUIDGenerateUtil;

/**
 * 类描述:这里是类描述
 * 
 * @ClassName: CarInAndOutController
 * @author Administrator
 * @date 2015年4月12日 下午8:07:54
 */
@RestController
@RequestMapping(value = "/index/inAndOutEx", method = RequestMethod.POST)
public class LocalIndexCarInAndOutExController extends BaseController
{
	
	private Log4jUtil log = Log4jUtil
			.getLog4j(LocalIndexCarInAndOutExController.class);
	
	@Autowired
	private CrossingService crossionService;
	@Autowired
	private ParkwellCarOutService carParkOutService;
	
	@Autowired
	protected CarInAndOutService carInAndOutService;
	
	@Autowired
	private CrossingService crossinService;
	
	@Autowired
	private LocalCarTypeMapper carTypeMapper;
	
	@Autowired
	private LogService logService;
	
	@Autowired
	private CarParkInMapper carParkInMapper;
	
	@Autowired
	private ParklotNumberMapper lotNumberMapper;
	
	
	@Autowired
	private CarParkOutMapper carParkOutMapper;
	
	@Autowired
	private CarParkOutCopyMapper carParkOutCopyMapper;
	
	
	@Autowired
	private LogService logServier;
	
	/**
	 * 
	 * 方法描述： 平台下发指令后是否成功.
	 * 
	 * @Title: whenIssuedIsSucceed
	 * @param @param instructVo
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年4月13日
	 * @throws
	 */
	@RequestMapping(value = "/whenIssuedIsSucceed.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap whenIssuedIsSucceed(@RequestBody InstructVo instructVo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述： 添加车辆进场
	 * 
	 * @Title: addCarParkInBill
	 * @param @param carParkIn
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年4月2日
	 * @throws
	 */
	@RequestMapping(value = "/addCarParkInBill.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addCarParkInBill(@RequestBody CarParkIn carParkIn)
	{
		ModelMap resultMap = new ModelMap();
		Long startTime = System.currentTimeMillis();
		Long begainTime = startTime;
		
		try
		{
			// 判断是否重复纪录,如果是重复发送直接返回相机不处理任何信息
			if (RecordLockManager.instance().isLocked(carParkIn.getRecordId()))
			{
				resultMap.put("isOpen", false);
				//进场纪录行级锁(保证进场纪录能更新到图片)
				if(log.isDebugEnabled())
				{
				  log.debug("->进场纪录解锁重复纪录,主线程:"+Thread.currentThread().getId()+",纪录ID"+carParkIn.getRecordId() + ",车牌号:"+carParkIn.getCarNo());
				}
				return resultMap;
			}
			
			//进场纪录行级锁(保证进场纪录能更新到图片)
			if(log.isDebugEnabled())
			{
			  log.debug("->进场纪录加锁,主线程:"+Thread.currentThread().getId()+"纪录ID,"+carParkIn.getRecordId()+",车牌号:"+carParkIn.getCarNo());
			}
			
			RecordLockManager.instance().lock(carParkIn.getRecordId());
			
			// 是否开闸
			CarParkInOverVo cv = carInAndOutService
					.findOverAddCarParkInBill(carParkIn);
			
			if (log.isDebugEnabled())
			{
				log.debug(Thread.currentThread().getId() + "判断是否开闸结束:"
						+ (new Date().getTime() - startTime));
			}
			
			// 不开闸标识
			if (!Tools.isEmpty(cv) && cv.isOpen() == false)
			{
				resultMap.put("isOpen", false);
			}
			
			// 启动线程,插入进场记录和进场计费副本.如果开闸则上传数据到云,包括计费副本.并推送车位数量,和开闸状态以及是否弹框.
			if (!Tools.isEmpty(cv) && !Tools.isEmpty(cv.getCarparkIn()))
			{
				CarParkInLocalThread carInLocalThread = new CarParkInLocalThread(
						cv, carInAndOutService);
				ThreadPoolUtil.instance().execute(carInLocalThread);
			}
			
			// 进场数据云同步
			if (!Tools.isEmpty(cv) && cv.isOpen() == true)
			{
				resultMap.put("isOpen", true);
			}
			resultMap.put(CommonContans.RECORD_ID, carParkIn.getRecordId());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
			resultMap.put("isOpen", true);//如果主线程报错默认进场
			
			if(log.isDebugEnabled())
			{
			  log.debug("->进场纪录异常解锁:"+carParkIn.getRecordId() + ",车牌号:"+carParkIn.getCarNo());
			}
			
			RecordLockManager.instance().removeLock(carParkIn.getRecordId());
		} 
		
		System.out.println(Thread.currentThread().getId() + "入场结束,总耗时:"
				+ (System.currentTimeMillis() - begainTime) + " 毫秒.");
		
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述： 设备扫描到车牌时上报出场,判断自动出场
	 * 
	 * @Title: addCarParkOutBill
	 * @param @param carParkOut
	 * @param @return
	 * @return ModelMap
	 * @user Administrator 2015年4月2日
	 * @throws
	 */
	@RequestMapping(value = "/addCarParkOutBill.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addCarParkOutBill(@RequestBody CarParkOut carParkOut)
	{
		long timeStart = System.currentTimeMillis();
		ModelMap resultMap = new ModelMap();
		ParkwellPayBillVo parkwellPayBillVo = new ParkwellPayBillVo();
		int price = 0;
		
		try
		{
			// 判断是否是重复标记,如果重复纪录 2016-3-27
			if (RecordLockManager.instance()
					.isLocked(carParkOut.getRecordId()))
			{
				if(log.isDebugEnabled())
				{
				   log.debug("--->开始解锁重复数据(出),处理出场主线程线程ID："+carParkOut.getRecordId() + "，车牌号:"+carParkOut.getCarNo());
				}
				
				
				resultMap.put("isOpen", false);
				parkwellPayBillVo.setResult(false);
				parkwellPayBillVo.setRepetition(true);
				resultMap.put(CommonContans.STRUTS_RESULT,
						CommonContans.STRUTS_SUCCESS);
				resultMap
						.put(CommonContans.RECORD_ID, carParkOut.getRecordId());
				resultMap.put("pay", price);
				parkwellPayBillVo.setRepetition(true); // 重复数据前台不弹出框
				return resultMap;
			}
			
			
			//出场纪录行级锁(保证进场纪录能更新到图片)
			RecordLockManager.instance().lock(carParkOut.getRecordId());
			if(log.isDebugEnabled())
			{
				log.debug("--->开始加锁(出),处理出场主线程线程ID"+Thread.currentThread().getId()+","+carParkOut.getRecordId() + "，车牌号:"+carParkOut.getCarNo());
			}

			// 插入出场纪录
			if (Tools.isEmpty(carParkOut.getCarNo()))
			{
				carParkOut.setCarNo("无效车牌");
			}
			
			carParkOut.setUuid(UUIDGenerateUtil.generate());
			carParkOut.setStatus(1);// 待出场
			carParkOut.setCreateTime(new Date());
			carParkOut.setOpenTime(DateTools.dateToString(
					carParkOut.getCreateTime(),
					DateFormatString.yyyy_MM_dd_HH_mm_ss_H));
			
			// carParkOutService.carOut(carParkOut, parkwellPayBillVo);
			// 2016-3-25 判断是否能开闸,直接响应相机.
			long virtuaStartTime = System.currentTimeMillis();
			if(log.isDebugEnabled())
			{
				log.debug("-->计费方法执行,主线程ID"+Thread.currentThread().getId() +"," +carParkOut.getRecordId() + "车牌号" + carParkOut.getCarNo());
			}
			carParkOutService.queryGenerateVirtualBill(carParkOut,
					parkwellPayBillVo);
			long virtuaEndTime = System.currentTimeMillis();
			
			if(log.isDebugEnabled())
			{
				log.debug("-->计费方法结束，主线程ID"+Thread.currentThread().getId()+"," +carParkOut.getRecordId() + "车牌号" + carParkOut.getCarNo() + "总耗时:"+(virtuaEndTime-virtuaStartTime)+"毫秒.");
			}
			
			if (!parkwellPayBillVo.isResult())
			{
				virtuaStartTime = System.currentTimeMillis();
				
				resultMap.put("isOpen", false);
				// 启动线程，标记插入待出场纪录，并上传到云平台，推送前端页面
				StayCarOutThread stayCarOutRunble = new StayCarOutThread(
						carParkOutMapper, logService, carParkOut,
						carInAndOutService, parkwellPayBillVo, crossinService);
				ThreadPoolUtil.instance().execute(stayCarOutRunble);
				
				//LED屏幕显示&播报.
				if(!Tools.isEmpty(parkwellPayBillVo.getScreenMsg())&&Tools.isEmpty(parkwellPayBillVo.getCarInUuid())){
					ParkTwoScreenMsgThread parkScreenMsgThread = new ParkTwoScreenMsgThread(parkwellPayBillVo.getScreenMsg(), parkwellPayBillVo.getScreen());
					ThreadPoolUtil.instance().execute(parkScreenMsgThread);
				}
				virtuaEndTime = System.currentTimeMillis();
				
				
			} else
			{
				virtuaStartTime = System.currentTimeMillis();
				
				// 自动开闸，插入出场数据并拷贝到出场副本表、删除进场记录表（拷贝到副本），删除计费副本、打印流水、上传到云、推送车位数、推送前端
				CarParkOutThread carOutRunble = new CarParkOutThread(
						carParkOutService, parkwellPayBillVo, carParkOut,
						carParkInMapper, lotNumberMapper, logService,
						carInAndOutService, crossinService);
				/* carParkOutService.carOutNew(parkwellPayBillVo, carParkOut); */
				ThreadPoolUtil.instance().execute(carOutRunble);
				if(!Tools.isEmpty(parkwellPayBillVo.getScreenMsg())){
					ParkTwoScreenMsgThread parkScreenMsgThread = new ParkTwoScreenMsgThread(parkwellPayBillVo.getScreenMsg(), parkwellPayBillVo.getScreen());
					ThreadPoolUtil.instance().execute(parkScreenMsgThread);
				}
				virtuaEndTime = System.currentTimeMillis();
				
				
			}
			
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			parkwellPayBillVo.setResult(true); //主线程报错，默认开闸机
			resultMap.put(CommonContans.STTURS_ERRORMSG,
					parkwellPayBillVo.getErrorMsg());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_ERROR);
			
			if(log.isDebugEnabled())
			{
			   log.debug("--->解锁计费方法异常(出)："+carParkOut.getRecordId() + "，车牌号:"+carParkOut.getCarNo());
			}
			RecordLockManager.instance().removeLock(carParkOut.getRecordId());
		} finally
		{
			long virtuaStartTime = System.currentTimeMillis();
			if(log.isDebugEnabled())
			{
				log.debug("-->执行finally方法,线程ID"+Thread.currentThread().getId()+","+ carParkOut.getRecordId() + "车牌号" + carParkOut.getCarNo() + "开闸标记:" + parkwellPayBillVo.isResult());
			}
			
			// 返回相机信息
			resultMap.put("isOpen", parkwellPayBillVo.isResult());
			resultMap.put(CommonContans.RECORD_ID, carParkOut.getRecordId());
			price = !Tools.isEmpty(parkwellPayBillVo)
					&& !Tools.isEmpty(parkwellPayBillVo.getPriceDifference()) ? parkwellPayBillVo
					.getPriceDifference().intValue() : 0;
			resultMap.put("pay", price);
			//resultMap.put("msg", parkwellPayBillVo.getScreenMsg());
			long timeEnd = System.currentTimeMillis();
			if(log.isDebugEnabled())
			{
				log.debug("-->-->执行finally方法，线程ID"+Thread.currentThread().getId()+","+ carParkOut.getRecordId()+ "车牌号:" + carParkOut.getCarNo() + "-总耗时:"+(timeEnd-virtuaStartTime)+"毫秒.");
			}
			System.out.println("出场recordId:"+ carParkOut.getRecordId() + "车牌号" + carParkOut.getCarNo()+"线程ID" + Thread.currentThread().getId() + "->"
					+ carParkOut.getCarNo() + " 总耗时(take time):"
					+ (timeEnd - timeStart) + "毫秒(millisecond).\n");
			
		}
		
		return resultMap;
	}
	
	public CarParkOutCopy returnCarInCopy(CarParkOut carParkOut)
	{
		CarParkOutCopy carParkOutCopy = new CarParkOutCopy();
		if (Tools.isEmpty(carParkOut))
		{
			return null;
		}
		if (Tools.isEmpty(carParkOut.getUuid()))
		{
			carParkOutCopy.setUuid(UUIDGenerateUtil.generate());
		}
		if (!Tools.isEmpty(carParkOut.getUuid()))
		{
			carParkOutCopy.setUuid(carParkOut.getUuid());
		}
		if (!Tools.isEmpty(carParkOut.getCarNo()))
		{
			carParkOutCopy.setCarNo(carParkOut.getCarNo());
		}
		if (!Tools.isEmpty(carParkOut.getCreateTime()))
		{
			carParkOutCopy.setCreateTime(carParkOut.getCreateTime());
		}
		if (!Tools.isEmpty(carParkOut.getPic1()))
		{
			carParkOutCopy.setPic1(carParkOut.getPic1());
		}
		if (!Tools.isEmpty(carParkOut.getPic2()))
		{
			carParkOutCopy.setPic2(carParkOut.getPic2());
		}
		if (!Tools.isEmpty(carParkOut.getExchangeUuid()))
		{
			carParkOutCopy.setExchangeUuid(carParkOut.getExchangeUuid());
		}
		if (!Tools.isEmpty(carParkOut.getEquipment()))
		{
			carParkOutCopy.setEquipment(carParkOut.getEquipment());
		}
		if (!Tools.isEmpty(carParkOut.getOpenTime()))
		{
			carParkOutCopy.setOpenTime(carParkOut.getOpenTime());
		}
		if (!Tools.isEmpty(carParkOut.getCarInUuid()))
		{
			carParkOutCopy.setCarInUuid(carParkOut.getCarInUuid());
		}
		if (!Tools.isEmpty(carParkOut.getPayStatus()))
		{
			carParkOutCopy.setPayStatus(carParkOut.getPayStatus());
		}
		if (!Tools.isEmpty(carParkOut.getRecordId()))
		{
			carParkOutCopy.setRecordId(carParkOut.getRecordId());
		}
		if (!Tools.isEmpty(carParkOut.getStatus()))
		{
			carParkOutCopy.setStatus(carParkOut.getStatus());
		}
		return carParkOutCopy;
	}
	
	/**
	 * 
	 * 方法描述： 单击处理时显示当前出场车辆所产生费用,此方法用于无法自动出场和计价
	 * 
	 * @Title: showCarParkOutBill
	 * @param @param uuid
	 * @param @return
	 * @return ModelMap
	 * @user lyf 2015年11月8日
	 * @throws
	 */
	@RequestMapping(value = "/showCarOutBill.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap showCarOutBill(
			@RequestBody ShowCarOutBillParameterVo carOutShow)
	{
		ModelMap resultMap = new ModelMap();
		ParkwellPayBillVo billVo = new ParkwellPayBillVo();
		billVo.setCarInUuid(carOutShow.getCarInUuid());
		billVo.setCarNo(carOutShow.getCarNo());
		
		try
		{
			CarParkOut carOut = carParkOutMapper.selectByPrimaryKey(carOutShow
					.getCarOutUuid());
			
			// 2016-2-27 添加软键盘自动输入车牌，通过车牌搜索车牌号码
			if (!Tools.isEmpty(carOutShow.getCarNo())
					&& Tools.isEmpty(carOutShow.getCarOutUuid()))
			{
				carOut = carParkOutMapper.selectCarNo(carOutShow.getCarNo());
			}
			// end
			
			if (!Tools.isEmpty(carOutShow.getCarNo()) && !Tools.isEmpty(carOut))
			{
				carOut.setCarNo(carOutShow.getCarNo());
			}
			
			if (!Tools.isEmpty(carOut))
			{
				if (!Tools.isEmpty(carOutShow.getCarInUuid()))
				{
					carOut.setCarInUuid(carOutShow.getCarInUuid());
				}
				
				carParkOutService.queryGenerateVirtualBill(carOut, billVo);
				int price = !Tools.isEmpty(billVo)
						&& !Tools.isEmpty(billVo.getPriceDifference()) ? billVo
						.getPriceDifference().intValue() : 0;
				if(!Tools.isEmpty(billVo.getScreenMsg())&&price!=0){
					ParkTwoScreenMsgThread parkScreenMsgThread = new ParkTwoScreenMsgThread(billVo.getScreenMsg(), billVo.getScreen());
					ThreadPoolUtil.instance().execute(parkScreenMsgThread);
				}
				resultMap.put(CommonContans.STRUTS_DATA, billVo);
			}
			
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			resultMap.put(CommonContans.STRUTS_DATA, billVo);
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述： 相机异步同步进场出场图片信息
	 * 
	 * @Title: updateCarBill
	 * @param @param carBillVo
	 * @param @return
	 * @return ModelMap
	 * @user lyf 2015年11月5日
	 * @throws
	 */
	@RequestMapping(value = "/updateCarBill.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap updateCarBill(@RequestBody CarBillVo carBillVo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			if (log.isDebugEnabled())
			{
				log.debug("处理相机图片主线程ID"+Thread.currentThread().getId() + ",纪录ID:" +carBillVo.getEquipment()
						+ carBillVo.getRecordId() + "->" + carBillVo.getPic1()
						+ "->" + carBillVo.getPic2());
			}
			//carInAndOutService.asyncPhotoForInOrOut(carBillVo);
			//使用异步线程更新进出场纪录、防止中间件报 read time out 异常
			FtpImageUpThread upImageRunble = new FtpImageUpThread(carBillVo, carInAndOutService,crossionService);
			ThreadPoolUtil.instance().execute(upImageRunble);
			
			resultMap.put(CommonContans.RECORD_ID, carBillVo.getRecordId());
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	@RequestMapping(value = "/calculateBillPrice.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap calculateBillPrice(
			@RequestBody CalculateBillPriceVo calulatVo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			
			if (Tools.isEmpty(calulatVo.getCarTypeUuid()))
			{
				LocalCarType carType = new LocalCarType();
				carType.setCartypeId("MIN_CAR");
				String carTypeUuid = carTypeMapper.queryCarType(carType)
						.getCarTypeUuid();
				calulatVo.setCarTypeUuid(carTypeUuid);
			}
			
			SimpleDateFormat simpFromt = new SimpleDateFormat(
					"yyyy-MM-dd hh:mm:ss");
			Date inDate = !Tools.isEmpty(calulatVo.getCarInTime()) ? simpFromt
					.parse(calulatVo.getCarInTime()) : new Date();
			Date outDate = new Date(System.currentTimeMillis());
			
			Double price = carParkOutService.queryCalculatePrice(inDate,
					outDate, calulatVo.getCarTypeUuid(),
					new ParkwellPayBillVo());
			
			String timeLong = MyDateUtil
					.periodToString((outDate.getTime() - inDate.getTime()));
			
			resultMap.put("timeLong", timeLong);
			resultMap.put("price", price);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：相机断开调用
	 * 
	 * @Title: equimentError
	 * @param @param equimentErroVo
	 * @param @return
	 * @return ModelMap
	 * @user lyf 2015年11月26日
	 * @throws
	 */
	@RequestMapping(value = "/equimentError.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap equimentError(@RequestBody EquimentErroVo equimentErroVo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			// 断开
			if (!Tools.isEmpty(equimentErroVo)
					&& equimentErroVo.getState() == 1)
			{
				Log logInfo = new Log();
				logInfo.setSummary("相机断开");
				logInfo.setDescript(equimentErroVo.getCeviceNumber()
						+ "断开连接，创建时间:" + equimentErroVo.getConnTime()
						+ "，IP地址:" + equimentErroVo.getIp() + ".");
				logInfo.setLevel(LogInfoConstan.LEVEL_SERIOUS);
				logInfo.setSrc(LogInfoConstan.SRC_SYSTEM);
				logInfo.setStatus(LogInfoConstan.STATUS_UNTREATED);
				logInfo.setCls("LocalIndexCarInAndOutExController");
				logInfo.setModule(LogInfoConstan.MODULE_equiment_error);
				logInfo.setBusinessUuid(equimentErroVo.getCeviceNumber());
				logService.addLogInfo(logInfo);
			}
			
			// 重新注册
			if (!Tools.isEmpty(equimentErroVo)
					&& equimentErroVo.getState() == 2
					&& !Tools.isEmpty(equimentErroVo.getCeviceNumber()))
			{
				LogExample logEx = new LogExample();
				logEx.or().andBusinessUuidEqualTo(
						equimentErroVo.getCeviceNumber().trim());
				logService.deleteByCondition(logEx);
			}
			
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述： 查询是否有进场车辆
	 * 
	 * @Title: findCarInByCarNo
	 * @param @param carNo
	 * @param @return
	 * @return ModelMap
	 * @user lyf 2016年2月28日
	 * @throws
	 */
	@RequestMapping(value = "/findCarInByCarNo.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap findCarInByCarNo(@RequestBody ShowCarOutBillParameterVo vo)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			CarParkIn carIn = carInAndOutService
					.findCarInByCarNo(vo.getCarNo());
			
			resultMap.put(CommonContans.STRUTS_DATA,
					Tools.isEmpty(carIn) ? "false" : true);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	
	/**
	 * 
	 * 方法描述：根据出场ID查询出场详情
	 * @Title: findCarOutInfoByCarOutUuid 
	 * @param @param vo
	 * @param @return
	 * @return ModelMap
	 * @user pichunhan
	 * 2016年4月18日
	 * @throws
	 */
	@RequestMapping(value = "/findCarOutInfoByCarOutUuid.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap findCarOutInfoByCarOutUuid(String uuid)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			CarOutInfoVo carOutInfoVo = carInAndOutService.findCarOutInfoByCarOutUuid(uuid);
			resultMap.put(CommonContans.STRUTS_DATA, carOutInfoVo);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
	
	/**
	 * 
	 * 方法描述：旧版本转换新版本使用
	 * @Title: convertCarIn 
	 * @param @return
	 * @return ModelMap
	 * @user pichunhan
	 * 2016年4月28日
	 * @throws
	 */
	@RequestMapping(value = "/convertCarIn.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap convertCarIn(){
		ModelMap resultMap = new ModelMap();
		try
		{
			carInAndOutService.convertCarIn();
			//根据当前操作用户，获取当前停车场。
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_ERROR);
		}finally{
			return resultMap;
		}
	}
	
	
	
}
